namespace Zj.HttpCodeDemo.Repository.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class ConCurrentCheckConfig_ : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.Category",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        Name = c.String(nullable: false, maxLength: 16),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.News",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        Title = c.String(nullable: false, maxLength: 30),
                        Keyword = c.String(nullable: false, maxLength: 5),
                        Description = c.String(nullable: false, maxLength: 255),
                        Content = c.String(nullable: false),
                        RowVersion = c.Binary(nullable: false, fixedLength: true, timestamp: true, storeType: "rowversion"),
                        CategoryId = c.Guid(nullable: false),
                        UserId = c.Guid(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.User", t => t.UserId, cascadeDelete: true)
                .ForeignKey("dbo.Category", t => t.CategoryId, cascadeDelete: true)
                .Index(t => t.CategoryId)
                .Index(t => t.UserId);
            
            CreateTable(
                "dbo.Tag",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        Name = c.String(nullable: false, maxLength: 16),
                        Order = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.User",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        UserName = c.String(nullable: false, maxLength: 16),
                        Pwd = c.String(nullable: false, maxLength: 32),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.UserInfo",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        Mobile = c.String(nullable: false, maxLength: 13),
                        Mail = c.String(nullable: false, maxLength: 20),
                        Age = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.User", t => t.Id)
                .Index(t => t.Id);
            
            CreateTable(
                "dbo.NewsTag",
                c => new
                    {
                        NewsId = c.Guid(nullable: false),
                        TagId = c.Guid(nullable: false),
                    })
                .PrimaryKey(t => new { t.NewsId, t.TagId })
                .ForeignKey("dbo.News", t => t.NewsId, cascadeDelete: true)
                .ForeignKey("dbo.Tag", t => t.TagId, cascadeDelete: true)
                .Index(t => t.NewsId)
                .Index(t => t.TagId);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.News", "CategoryId", "dbo.Category");
            DropForeignKey("dbo.News", "UserId", "dbo.User");
            DropForeignKey("dbo.UserInfo", "Id", "dbo.User");
            DropForeignKey("dbo.NewsTag", "TagId", "dbo.Tag");
            DropForeignKey("dbo.NewsTag", "NewsId", "dbo.News");
            DropIndex("dbo.NewsTag", new[] { "TagId" });
            DropIndex("dbo.NewsTag", new[] { "NewsId" });
            DropIndex("dbo.UserInfo", new[] { "Id" });
            DropIndex("dbo.News", new[] { "UserId" });
            DropIndex("dbo.News", new[] { "CategoryId" });
            DropTable("dbo.NewsTag");
            DropTable("dbo.UserInfo");
            DropTable("dbo.User");
            DropTable("dbo.Tag");
            DropTable("dbo.News");
            DropTable("dbo.Category");
        }
    }
}
